import { useState } from 'react';
import Todohead from './Todohead'
import List from './list';
import classs from './Todolist.module.scss'
import ContextTodo, { state } from './todoContext';
const TodoList = () => {
  const [todoList, setToList ] = useState(state)
  
  const updateList=(val)=>{
    // console.log(val)
    let objTodo = {...todoList}
    objTodo.todoList.push(val)
    setToList(()=>{
      return {
        todoList:objTodo.todoList
      }
    })
  }
  return (
    <div className="TodoList">
      <div className={classs.content}>
        <ContextTodo.Provider value={{...todoList,updateList}}>
          <Todohead></Todohead>
          <List></List>
        </ContextTodo.Provider>
      </div>
    </div>
  );
}

export default TodoList;